package com.wang;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;

class MyClass<T> {
}

class MyNonGenericClass {
}

public class Main {
    public static void main(String[] args) {
        Class<?> genericClass = MyClass.class;
        Class<?> nonGenericClass = MyNonGenericClass.class;
        MyClass myClass = new MyClass();

        boolean isGeneric = isGenericClass(genericClass);
        System.out.println(genericClass.getName() + " is generic? " + isGeneric); // 输出 "MyClass is generic? true"

        boolean isNonGeneric = isGenericClass(nonGenericClass);
        System.out.println(nonGenericClass.getName() + " is generic? " + isNonGeneric); // 输出 "MyNonGenericClass is generic? false"
    }

    public static boolean isGenericClass(Class<?> clazz) {
        TypeVariable<?>[] typeParameters = clazz.getTypeParameters();
        return typeParameters.length > 0;
    }
}
